package easymall.dao;

import easymall.po.Order;
import easymall.pojo.MyPage;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;


@Mapper
public interface OrderDao {
	@Insert("insert into orders(id,money,receiverinfo,state,ordertime,user_id) values(#{id},#{money},#{receiverinfo},#{state},#{ordertime},#{user_id})")
	public void addOrder(Order order);

	@Select("select * from orders where user_id = #{user_id} order by ordertime desc")
	public List<Order> findOrderByUserId(Integer user_id);

	@Delete("delete from orders where id = #{id}")
	public void delOrder(String id);

	@Update("update orders set state='未发货' where id=#{id}")
	public void payOrder(String id); //修改订单的状态从未付款->未发货

	@Update("update orders set state='已完成' where id=#{id}")
	public void confirmOrder(String id);//修改订单的状态从已发货-已完成（确认收货）

	@Update("update orders set state='已发货',expressnumber=#{expressnumber} where id=#{id}")
	public void sendOrder(Order order);

	@Select("select * from orders limit #{skip},#{size}")
	public List<Order> getOrdersByPage(MyPage page); //查询所有订单

	@Select("select count(*) from orders")
	public int getOrdersCount();//获取总分类数

	@Select("select * from orders where id = #{id}")
	public Order getOrderById(String id);//根据订单号获取订单信息

	@Select("select * from orders")
	public List<Order> findAllOrders();
	
}
